package com.raising.sc;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


/**
 * 使用 @EnableCircuitBreaker 或 @EnableHystrix 注解开启Hystrix
 *
 *  @EnableHystrix 里面包含了 @EnableCircuitBreaker
 *
 * 使用 @SpringCloudApplication =
 *              @EnableDiscoveryClient +
 *              @SpringBootApplication +
 *              @EnableHystrix
 */
//@EnableDiscoveryClient
//@SpringBootApplication
//@EnableHystrix
@SpringCloudApplication
@EnableHystrixDashboard
public class ServiceCRibbonHystrixApplication
{
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static void main(String[] args) {
        new SpringApplicationBuilder(ServiceCRibbonHystrixApplication.class).web(true).run(args);
    }
}
